﻿using UnityEngine;
using System.Collections;

public class ball : MonoBehaviour {

	public Vector3 initialImpulse;

	// Use this for initialization
	void Start () {
		rigidbody.AddForce (initialImpulse, ForceMode.Impulse);
	
	}
	
	// Update is called once per frame
	void Update () {
		rigidbody.velocity = rigidbody.velocity.normalized * initialImpulse.magnitude;
	
	}

	void OnCollisionEnter(Collision collision)
	{
		Vector3 muuttuja = Vector3.Reflect (transform.position , collision.contacts[0].normal);
		rigidbody.AddForce (muuttuja, ForceMode.Impulse);
		/*foreach (ContactPoint contact in collision.contacts) {
		Vector3 muuttuja = Vector3.Reflect (transform.position , contact.normal);
		rigidbody.AddForce (muuttuja, ForceMode.Impulse);
}*/
	}

}
